#ifndef MOONLIGHT_OHOS_CANCELLABLETIMER_H
#define MOONLIGHT_OHOS_CANCELLABLETIMER_H

#include <future>

class CancellableTimer {
public:
    CancellableTimer(int32_t delayMs, std::function<void()> &&fn);
    CancellableTimer(const std::string_view name, int32_t delayMs, std::function<void()> &&fn);
    virtual ~CancellableTimer();

private:
    const std::string name;
    std::future<void> timer;
    mutable std::mutex mtx;
    std::condition_variable cancelCond;
};

#endif //MOONLIGHT_OHOS_CANCELLABLETIMER_H
